import { service } from '@/service'

enum Api {
  list = 'system/menu/list',
  Edit = 'system/menu',
  Tree = 'system/menu/treeselect'
}

export const menuList = (params: any) => {
  return service.request({
    url: Api.list,
    method: 'GET',
    params
  })
}

export const menuAdd = (data: any) => {
  return service.request({
    url: Api.Edit,
    method: 'POST',
    data
  })
}

export const menuDetails = (id: number) => {
  return service.request({
    url: `${Api.Edit}/${id}`,
    method: 'GET'
  })
}

export const menuEdit = (id: number, data: any) => {
  return service.request({
    url: `${Api.Edit}`,
    method: 'PUT',
    data
  })
}

export const menuDel = (ids: any[]) => {
  return service.request({
    url: `${Api.Edit}/${ids.join()}`,
    method: 'DELETE'
  })
}

// 树
export const menuTreeselect = (params?: any) => {
  return service.request({
    url: Api.Tree,
    method: 'GET',
    params
  })
}

export const menuTreeselectDetails = (id: number) => {
  return service.request({
    url: `${Api.Tree}/${id}`,
    method: 'GET'
  })
}
